<?php if(isset($offers) && is_array($offers) && !empty($offers)){?>
			
<table class="offers">			
	<tr>			
			<?php
			// liczba rekordow
			$catsCnt = count($offers);
			$columns = 3;
			
			foreach ($offers as $k => $offer):
				$image = (isset($offer['ViewOffer']['image'])) ? $offer['ViewOffer']['image'] : '&nbsp;';
				$image_link = $this->Html->link($fileUpload->image($image,array('autoResize'=>true,'width'=>170,'imagePathOnly'=>false))
					,array('controller'=>'offers','action' => 'view', $offer['ViewOffer']['id'],Inflector::slug($offer['ViewOffer']['miasto'],'-'))
					,array('escape'=>false,'title'=>'Oferta nieruchomości LEX w '.$offer['ViewOffer']['miasto'],', ulica: '.$offer['ViewOffer']['ulica']));
				$miasto = '<span class="miasto">'.$offer['ViewOffer']['miasto'].'</span>';
				$dzielnica = (!empty($offer['ViewOffer']['dzielnica'])) ? '<br/><span class="dzielnica">'.$offer['ViewOffer']['dzielnica'].'</span>' : '';
				$ulica = (!empty($offer['ViewOffer']['ulica'])) ? '<br/>ulica: <span class="ulica">'.str_replace('ul.','',$offer['ViewOffer']['ulica']).'</span>' : '';
				$region_link =  $this->Html->link($miasto. ' '.$dzielnica. ' '.$ulica
					, array('controller'=>'offers','action' => 'view', $offer['ViewOffer']['id'],Inflector::slug($offer['ViewOffer']['miasto']. '-'.$offer['ViewOffer']['dzielnica']. '-'.$offer['ViewOffer']['ulica'],'-'))
					, array('escape'=>false,'title'=>'Oferta nieruchomości LEX w '.$offer['ViewOffer']['miasto'],', ulica: '.$offer['ViewOffer']['ulica']));

				$powierzchnia = __('Powierzchnia: <span class="powierzchnia">',true). $offer['ViewOffer']['powierzchnia_od'].'m<sup>2</sup></span>';	
				$typ = 	$offer['ViewOffer']['typ_name'];
				$transakcja = 	$offer['ViewOffer']['transakcja_name'];
			?>

			<?php
			
			$form = $this->Form->create('Offer',array('url'=>array('controller'=>'offers','action'=>'edit')));
			$form .= "<table class=\"change-offer-promoton\"><tr><td>";
			$form .= $this->Form->input('id',array('value'=>$offer['ViewOffer']['id']));
			$form .= $this->Form->input('promocja',array('label'=>false,'value'=>$offer['ViewOffer']['promocja'],'options'=>array(1=>__('Promocje',true),2=>__('Baner',true),3=>__('Promocje & Baner',true)),'empty'=>'','div'=>false));
			$form .= "</td><td>";
			$form .= $this->Form->submit(__('Zmień', true),array('div'=>false));
			$form .= "</td><tr></table>";
			$form .= $this->Form->end();
			?>
			
			<?php     	
				if(($k+1) % $columns == 0) { 
					echo "<td width=\"".(100/$columns)."%\" valign=\"bottom\" align=\"center\" class=\"last\">";
					
			?>

				<p class="lokalizacja"><?php echo $region_link?> </p>
				<div class="clear">&nbsp;</div>
				<div class="clear">&nbsp;</div>
				<p class="powirzchnia"><?php echo $powierzchnia ?></p>
				<h2><?php echo $typ ?></h2>
				<div class="image-icons-list">			
					<?php echo $image_link?>
					<div class='clear'>&nbsp;</div>					
				</div>
				<span><?php echo $transakcja?></span>
				<div class="clear">&nbsp;</div>
				<div class="cena"><?php echo $this->Number->currency($offer['ViewOffer']['cena_od'],'',array('after'=>'zł','thousands'=> ' ','places'=>0))?> </div><div class="offer-more"><?php echo $this->Html->link($this->Html->image(HOST.'/menu-more.png'),array('controller'=>'offers','action' => 'view', $offer['ViewOffer']['id'],Inflector::slug($offer['ViewOffer']['miasto']. '-'.$offer['ViewOffer']['dzielnica'],'-')),array('escape'=>false))?></div>
				
				<div class="clear">&nbsp;</div>
				<?php
				if($session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'admin' || $session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'manag'){
					echo $form;
				}
				?>				
				
			<?php echo "</td></tr>"; 
			      if ($k!=($catsCnt-1)) echo "<tr>"; 
			        } else { 
			       echo "<td width=\"".(100/$columns)."%\" valign=\"bottom\" align=\"center\">";			    
			?>
			
				<p class="lokalizacja"><?php echo $region_link?> </p>
				<div class="clear">&nbsp;</div>
				<p class="powirzchnia"><?php echo $powierzchnia ?></p>
				<div class="clear">&nbsp;</div>
				<h2><?php echo $typ ?></h2>

				<div class="image-icons-list">			
					<?php echo $image_link?>
					<div class='clear'>&nbsp;</div>					
				</div>	
				<span><?php echo $transakcja?></span>
				<div class="clear">&nbsp;</div>
				<div class="cena"><?php echo $this->Number->currency($offer['ViewOffer']['cena_od'],'',array('after'=>'zł','thousands'=> ' ','places'=>0))?> </div><div class="offer-more"><?php echo $this->Html->link($this->Html->image(HOST.'/menu-more.png'),array('controller'=>'offers','action' => 'view', $offer['ViewOffer']['id'],Inflector::slug($offer['ViewOffer']['miasto']. '-'.$offer['ViewOffer']['dzielnica'],'-')),array('escape'=>false))?></div>
				
				<div class="clear">&nbsp;</div>
				<?php
				if($session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'admin' || $session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'manag'){
					echo $form;
				}
				?>				
				
			<?php echo "</td>"; 
			    	}
			 ?> 
			<?php endforeach; ?>
			<?php 	// uzupełnienie ostatniego rekordu
				$numSpaces = $columns - ($catsCnt % $columns); 
			    if ($numSpaces!=0 && $numSpaces != $columns ) { 
			        for ($j=0;$j<$numSpaces;$j++) { 
			        	$last = ($j == $numSpaces -1) ? "class=\"last\"" :"";
			            echo "<td  width=\"".(100/$columns)."%\" {$last}>&nbsp;</td>"; 
			        } 
			        echo "</tr>"; 
			    }
			?>					
					
			</table>
										
<?php }?>